package it.unibo.android.convoycruisecontrol.boatsubsystem;

import java.io.File;

import com.google.android.maps.MapActivity;

import it.unibo.contact.boatSubSystem.BoatSubSystemLauncher;
import it.unibo.contact.platformuv.LindaLike;
import it.unibo.contact.platformuv.MsgUtil;
import it.unibo.contact.platformuv.RunTimeKb;
import it.unibo.convoycruisecontrol.boatsubsystem.AbstractCommandBoat;
import it.unibo.convoycruisecontrol.boatsubsystem.DashboardManager;
import it.unibo.convoycruisecontrol.boatsubsystem.IBoatFactory;
import it.unibo.convoycruisecontrol.boatsubsystem.IDashboard;
import it.unibo.convoycruisecontrol.boatsubsystem.SendingNavigationInfo;
import it.unibo.convoycruisecontrol.boatsubsystem.SensingBoatStatus;
import it.unibo.convoycruisecontrol.progettodesignandroid.R;
import it.unibo.convoycruisecontrol.progettodesignandroid.R.id;
import it.unibo.convoycruisecontrol.progettodesignandroid.R.layout;
import it.unibo.convoycruisecontrol.progettodesignandroid.R.menu;
import it.unibo.is.interfaces.IBasicEnv;
import it.unibo.is.interfaces.IOutputView;
import it.unibo.location.ILocationDeviceFactory;
import it.unibo.location.LocationDevice;
import it.unibo.util.information.InformationConverter;
import it.unibo.util.information.PrologInformationConverter;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

public class BoatActivity extends MapActivity 
{

	BoatSubSystemLauncher launcher;


	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);

		AlertDialog alertDialog = new AlertDialog.Builder(BoatActivity.this).create();
		alertDialog.setTitle("Boat Number");
		LayoutInflater inflater = this.getLayoutInflater();
		final View dialogView = inflater.inflate(R.layout.dialog_layout, null);
		alertDialog.setView(dialogView);
		alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {

				EditText boatNumberEditText = (EditText)dialogView.findViewById(R.id.boatNumber);
				int number = Integer.parseInt(boatNumberEditText.getText().toString());
				launch(number);
			}
		});
		alertDialog.show();
	}

	protected void launch(int boatNumber)
	{
		launcher = new AndroidBoatSubSystemLauncher(this);
		launcher.initConvoyInformations(new File("/data/convoy/convoy-android.xml"), boatNumber);
		launcher.doJob();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}
}
